package com.ba.grain;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.TableLayout;

public class CheckableLinearLayout extends TableLayout implements Checkable {
	public CheckableLinearLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		setChecked(false);
	}

	private boolean mChecked;

	public void setChecked(boolean checked) {
		mChecked = checked;
		setBackgroundDrawable((getResources()
				.getDrawable(checked ? R.drawable.item_list_bg_checked
						: R.drawable.item_list_bg_normal)));
	}

	public boolean isChecked() {
		return mChecked;
	}

	public void toggle() {
		setChecked(!mChecked);
	}

}
